# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Yangtse <yangtsesu@gmail.com>
# Contributor: WU Jun <quark at lihdd dot net>

pkgname=libpinyin
pkgver=2.8.1
_commit=de5bd732f9a6993938ce8fdcea9ecf7a00319c47
_modelver=19
pkgrel=1
pkgdesc="Library to deal with pinyin"
arch=('loong64' 'x86_64')
url="https://github.com/libpinyin/libpinyin"
license=('GPL')
depends=('kyotocabinet' 'glib2')
makedepends=('git' 'gnome-common')
source=("git+https://github.com/libpinyin/libpinyin.git#commit=$_commit"
        "$pkgname-model$_modelver.text.tar.gz::https://downloads.sourceforge.net/libpinyin/model$_modelver.text.tar.gz")
noextract=("$pkgname-model$_modelver.text.tar.gz")
sha512sums=('SKIP'
            '93c70423ba14faa3402bce775f82769dd4ee3a49083beddc540825f88facbd847328e9d01d99473adb7cf26de0f853e2b2e14fe849b1c49531134d1ca4ed2ef2')

prepare() {
  cd libpinyin

  ln -s "$srcdir"/$pkgname-model$_modelver.text.tar.gz data/model$_modelver.text.tar.gz
  sed -i "/wget.*model$_modelver\.text\.tar\.gz/ d" data/Makefile.am
}

build() {
  cd libpinyin
  ./autogen.sh --prefix=/usr --with-dbm=KyotoCabinet --enable-libzhuyin
  make
}

package() {
  cd libpinyin
  make DESTDIR="$pkgdir" install
}
